const RouterHook = require("../module/routerModule")
const router = RouterHook()
const dbUtil = require('../util/dbutil')
const { FieldUtils } = require("../util/utils")

/**
 * @swagger
 * /api/user/info:
 *    get:
 *      tags:
 *      - 用户接口
 *      summary: 获取用户信息
 *      produces:
 *      - application/json
 *      responses:
 *        200:
 *          description: 返回用户对象
 *          schema:
 *            type: object
 *            properties:
 *              xxx:
 *                type: object
 *                default: {}
 *        500:
 *          description: 账号密码错误
 *      security:
 *       - Authentication: {}
 *       - server_auth:
 *         - Authentication
 * */
router.get('/info', async (ctx) => {
  ctx.result.success(FieldUtils.FilterObjectNotIn(ctx.state.current, ['password']))
})

router.get('/string', async (ctx) => {
  ctx.body = 'koa2 string'
})

router.get('/json', async (ctx) => {
  ctx.result.success({
    title: 'koa2 json'
  })
}).noAuth()

module.exports = router
